home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / BUS / TMCM Software and Labs.sit / Software for TMCM 7_95 / Files For Lab 8 / EchoChars < prev    next >
Text File  |  1995-07-13  |  2KB  |  32 lines

  1. ; This program illustrates the I/O capabilities of xComputer.
  2. ; To use this program, you must turn on the "Use I/O Services"
  3. ; option in the "Options" menu.  (If this option is off, the
  4. ; computer will not recognize the I/O instructions gtc and ptc
  5. ; when the program is run.)
  6.  
  7. ; The program gets characters input by the user and echos them
  8. ; to output until the user types a carriage return.  Then the
  9. ; program terminates.
  10.  
  11.  
  12. get_ch:   gtc          ; Get the next char from input and load it into accumulator.
  13.           jmz get_ch   ; A value of zero indicates that no character was input.
  14.           sto ch       ; If the value is non-zero, save it in location "ch".
  15.                        ;   (Note that it is actually the ASCII code of the
  16.                        ;   character that is being saved here.)
  17.  
  18.           lod ch       ; Get the input char from location "ch" (into the AC).
  19.           sub-c 13     ; Compare it to "carriage return" by subtracting 13,
  20.                        ;        the ASCII code of a carriage return character.
  21.           jmz done     ; If it's a carriage return, jump to location "done".
  22.  
  23.           lod ch       ; Get the input char from location "ch".
  24.           ptc          ; Write the character (now in AC) to output.
  25.           jmp get_ch   ; Jump to "get_ch" to process the next character.
  26.  
  27. done:     hlt          ; Program ends.
  28.  
  29. ch:       data         ; Location to hold a character input from user
  30.                        ;                     while it is being processed.
  31.  
  32.